#include<reg51.h>

#define NODE2_ADDR 2

unsigned char i, j;
sbit LED = P3^7;
unsigned char num[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};

void display(unsigned ch) 
{
    if((ch>=48)&&(ch<=57)) 
        P0=num[ch-48];
    else if((ch>=65)&&(ch<=70)) 
        P0=num[ch-55];
}

void main()
{
    SCON = 0xf0;
    TMOD = 0x20;
    TH1 = TL1 = 0xfd;
    TR1 = 1;
    ES = 1;//串口
    EA = 1;
    while(1);
}

void receive() interrupt 4//串口中断
{
    RI = 0;
    if (RB8 == 1)
    {
        if (SBUF == NODE2_ADDR)
        {
            SM2 = 0;
            LED = !LED;
        }
        return;
    }
    display(SBUF);
    SM2 = 1;
}

